package uqbar.aspectj.utils;

import java.util.HashMap;
import java.util.Map;

public abstract class SimpleObject {
	static Map<Class<?>, Integer> ids = new HashMap<Class<?>, Integer>();
	private int id;
	
	public SimpleObject() {
		this.id = newId(this.getClass());
	}
	
	@Override
	public String toString() {
		return this.getClass().getSimpleName() + "_" + this.id ;
	}
	
	public static int newId(Class<?> cl) {
		Integer lastId = ids.get(cl);
		int newId = lastId == null ? 0 : lastId + 1;
		ids.put(cl, newId);
		return newId;
	}
}
